<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-06-28 16:23
 * Modified Time: 2019-06-28 16:23
 * Version: 2.0
 */

namespace App\Modules\Order\Criterias;


use Flower\Core\Repository\Contracts\CriteriaInterface;
use Flower\Core\Repository\Contracts\RepositoryInterface;

class findOrderAppStoreCriteria implements CriteriaInterface
{
	protected $where;

	public function __construct($requestData)
	{
		$this->where = $requestData;
	}

	public function apply($model, RepositoryInterface $repository)
	{
		// TODO: Implement apply() method.
		$map['store_id'] = $this->where['store_id'];

		if (isset($this->where['status'])) $map['status'] = $this->where['status'];
		if (isset($this->where['barber_id'])) $map['barber_id'] = $this->where['barber_id'];
		if (!empty($this->where['order_no'])) $map['order_no'] = $this->where['order_no'];
		if (!empty($this->where['member_id'])) $map['member_id'] = $this->where['member_id'];

		return $model->where($map)->orderBy('id', 'desc');
	}

}